package lumis.portal.page.serialization;

import java.util.ArrayList;
import java.util.List;

import lumis.portal.css.serialization.CssSerializableConfig;
import lumis.portal.metatag.MetaTagConfig;
import lumis.portal.serviceinterfaceinstance.serialization.ServiceInterfaceInstanceSerializableConfig;
import lumis.util.security.acl.serialization.AccessControlListSerializableConfig;

/**
 * Serializable value object for Page structure properties
 *
 * @version $Revision: 9324 $ $Date: 2008-05-20 10:06:04 -0300 (Tue, 20 May 2008) $
 * @since 4.0.7
 */
public class PageSerializableConfig
{
	private String id;
	private String name;
	private AccessControlListSerializableConfig accessControlList;
	private List<MetaTagConfig> metaTags = new ArrayList<MetaTagConfig>();
	private List<String> csss = new ArrayList<String>();
	private List<ServiceInterfaceInstanceSerializableConfig> serviceInterfaceInstances = new ArrayList<ServiceInterfaceInstanceSerializableConfig>();
	public String getId()
	{
		return id;
	}
	public void setId(String id)
	{
		this.id = id;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public AccessControlListSerializableConfig getAccessControlList()
	{
		return accessControlList;
	}
	public void setAccessControlList(AccessControlListSerializableConfig accessControlList)
	{
		this.accessControlList = accessControlList;
	}
	public List<ServiceInterfaceInstanceSerializableConfig> getServiceInterfaceInstances()
	{
		return serviceInterfaceInstances;
	}
	public List<MetaTagConfig> getMetaTags()
	{
		return metaTags;
	}
	public List<String> getCsss()
	{
		return csss;
	}
	private Object readResolve()
	{
		if (csss != null)
		{
			for (int i = 0; i < csss.size(); i++)
			{
				Object object = csss.get(i);
				if (object instanceof CssSerializableConfig)
					csss.set(i, null);
			}
		}
		
		// for backward compatibility, because LECs without metaTags element 
		// sets metaTags to null during deserialization
		if (metaTags == null)
			metaTags = new ArrayList<MetaTagConfig>();
		
		return this;
	}
}
